package nl.soekoor.recipes.dao.hibernate;

import nl.soekoor.recipes.dao.RecipeDao;
import nl.soekoor.recipes.data.Recipe;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class RecipeHibernateDAO extends HibernateDaoSupport implements RecipeDao{

	public void createRecipe(Recipe recipe){
		AnnotatedRecipe annotatedRecipe = new AnnotatedRecipe();
		annotatedRecipe.copyAnnotatedVersion(recipe);
		getHibernateTemplate().saveOrUpdate(annotatedRecipe);
	}

	public Recipe get(int recipeId) {
		AnnotatedRecipe annotatedRecipe = (AnnotatedRecipe)getHibernateTemplate().get(AnnotatedRecipe.class, new Integer(recipeId));
		Recipe recipe = annotatedRecipe.copyToDataVersion();
		return recipe;
	}
}

